package com.zzgc.modules.service.impl;

import com.zzgc.common.dao.StaticProvincialVisualizationDao;
import com.zzgc.common.entity.StaticProvincialVisualization;
import com.zzgc.modules.service.StaticProvincialVisualizationService;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;

import javax.annotation.Resource;
import java.util.List;

/**
 * (StaticProvincialVisualization)表服务实现类
 *
 * @author makejava
 * @since 2023-05-19 14:36:07
 */
@Service("staticProvincialVisualizationService")
public class StaticProvincialVisualizationServiceImpl implements StaticProvincialVisualizationService {
    @Resource
    private StaticProvincialVisualizationDao staticProvincialVisualizationDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public StaticProvincialVisualization queryById(Long id) {
        return this.staticProvincialVisualizationDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param staticProvincialVisualization 筛选条件
     * @return 查询结果
     */
    @Override
    public List<StaticProvincialVisualization> queryByPage(StaticProvincialVisualization staticProvincialVisualization) {
        return this.staticProvincialVisualizationDao.queryAllByLimit(staticProvincialVisualization);
    }

    /**
     * 新增数据
     *
     * @param staticProvincialVisualization 实例对象
     * @return 实例对象
     */
    @Override
    public StaticProvincialVisualization insert(StaticProvincialVisualization staticProvincialVisualization) {
        this.staticProvincialVisualizationDao.insert(staticProvincialVisualization);
        return staticProvincialVisualization;
    }

    /**
     * 修改数据
     *
     * @param staticProvincialVisualization 实例对象
     * @return 实例对象
     */
    @Override
    public StaticProvincialVisualization update(StaticProvincialVisualization staticProvincialVisualization) {
        this.staticProvincialVisualizationDao.update(staticProvincialVisualization);
        return this.queryById(staticProvincialVisualization.getId());
    }

    @Override
    public int restoreUnhealthy(Long id) {
        return this.staticProvincialVisualizationDao.restoreUnhealthy(id);
    }

    @Override
    public int restoreMyopiaRate(Long id) {
        return this.staticProvincialVisualizationDao.restoreMyopiaRate(id);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.staticProvincialVisualizationDao.deleteById(id) > 0;
    }
}
